package main

import (
	"gin_chat_demo/config/mysqlInit"
	"gin_chat_demo/config/redisInit"
	"gin_chat_demo/config/websocketInit"
	"gin_chat_demo/config/zap"
	"gin_chat_demo/router"
	"github.com/spf13/viper"
)

func main() {
	// zap init 日志
	zap.InitZap()
	// viper init 配置读取
	viper.SetConfigName("config")
	viper.SetConfigType("yaml")
	viper.AddConfigPath("./config")
	err := viper.ReadInConfig()
	if err != nil {
		panic("Failed to read configuration file")
	}
	port := viper.GetString("server.port")

	//mysql init
	mysqlInit.InitMysql(viper.GetString("mysql.dsn"), viper.GetString("mysql.jiangLaoDsn"), viper.GetString("mysql.csgoDsn"))

	//minio init
	//minioIniit.InitMinio(viper.GetString("minio.endpoint"), viper.GetString("minio.accessKeyID"), viper.GetString("minio.secretAccessKey"))

	//redis init
	redisInit.InitRedis(viper.GetString("redis.addr"), viper.GetString("redis.password"), viper.GetInt("redis.db"))
	//ws server
	websocketInit.InitWebsocket(viper.GetString("ws.addr"))

	//cronInit.InitCron()
	initRouter := router.InitRouter()
	initRouter.Run(":" + port)
}
